@extends('template.adminpage')
@section('content')

<ol class="breadcrumb">
  <li class="active">Packaging</li>
</ol>

<div class="container-black">
  <label style="margin-top:10px"><u>Pencarian</u></label>
  
	<form action="{{URL::to('/packagings')}}" method="POST">
         <div class="row">
          <div class="col-md-8">
            <div class="col-md-1">
              <input name="filter" value="type" type="radio" <?php if(Session::get('filter')=="type") echo "checked" ?> required ></input>
            </div>
            <div class="col-lg-2">
            <label>Type</label>
            </div>
            <div class="col-lg-4">
               <select  class="form-control" name="typeby" style="height:30px" >
            <?php
            $type = array('all'=>'All','Kemasan tidak pisah' => 'Kemasan tidak pisah', 'Kemasan pisah' => 'Kemasan terpisah');
            foreach ($type as $key => $val) {
                if ($key == Session::get('list')) {
                    echo '<option value="' . $key . '" selected>' . $val . '</option>';
                } else {
                    echo '<option value="' . $key . '">' . $val . '</option>';
                }
            }
            ?>
              </select>
            </div>
          </div>
          </div>
          <br>

          <div class="row">
          <div class="col-md-8">
            <div class="col-md-1">
              <input name="filter" value="keyword" type="radio"></input <?php if(Session::get('filter')=="keyword") echo "checked" ?>>
            </div>
            <div class="col-lg-2">
            <label>Nama kertas</label>
            </div>
            <div class="col-lg-4">
              <input type="text"  class="form-control" placeholder="Nama kertas" name="name" style="height:30px" value="{{Session::get('name')}}" ></input>
            </div>
          </div>
          </div>
          <br>
          <div class="row">
          <div class="col-md-8">
            <div class="col-md-4 col-md-offset-3">
                 <button class="btn btn-sm btn-dark" type="submit" style="width:100px;height:30px"><span class="fa fa-search"></span> Tampilkan</button>
            </div>
          </div>
          </div>
        

    </form>
    <br>
    <form action="{{URL::to('/packaging/deletepackaging')}}"  method="post" >
    <p><a data-toggle="modal" data-target="#addpackaging"><button class="btn btn-sm btn-dark" style="height:30px" ><span class="fa fa-plus"></span> Tambah</button></a> <button class="btn btn-sm btn-dark" type="submit" style="height:30px" ><span class="fa  fa-times"></span> Hapus</button></p>
  	 <?php
        $limit = 10;
        if(Input::get('page')==0 OR Input::get('page')==1){ 
         $no = 1;
        }
        else{
        $no = ((Input::get('page')-1)*$limit)+1;
        } ?>
     <table class="table table-bordered table-hover">
      <thead>
        <tr>
          <th><input type="checkbox" name="checkall" id="terserah" onclick="check_all('terserah', {{$no}})" ></input></th>
          <th>No</th>
          <th>Tipe packaging</th>
          <th>Nama kertas</th>
          <th>Ukuran (PxLxT) / Cm </th>
          <th>Harga</th>
          <th>Aksi</th>
        </tr>
      </thead>
      <tbody>
        
        @foreach($packagings as $packaging)
        <tr>
          <td><input type="checkbox" name="{{$packaging->packaging_id}}" value="1" id="terserah_{{$no}}" ></input></td>
          <td>{{$no}}</td>
          <td>{{$packaging->packaging_type}}</td>
          <td>{{$packaging->papertype_name}}</td>
          <td>{{$packaging->packaging_length.' x '.$packaging->packaging_width.' x '.$packaging->packaging_height}}</td>
          <td>Rp {{number_format($packaging->packaging_price,0,'.','.').' / '.$packaging->packaging_qty_price.' '.$packaging->packaging_qty_unit}}</td>
          <td><a data-toggle="modal" data-target="#{{$packaging->packaging_id}}"><button class="btn btn-xs btn-dark"><span class="fa fa-edit"></span> Ubah</button></a></td>
        </tr>
        <?php $no++; ?>
        @endforeach
      </tbody>
    </table>
     <div class="text-right"><?php echo $packagings->links(); ?></div>
  </form>
   

     <div class="modal fade" id="addpackaging" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="false">
                <div class="modal-dialog modal-lg">
                  <div class="modal-content">
                    <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
 
                    <h4 align="center" class="modal-title"> <label style="margin-top:5px; margin-bottom:25px">Tambah data fitur tambahan </label></h4>
                    </div>
                   <div align="left">
                   <br>
                          {{Form::open(array(
                                'url' => '/packaging/addpackaging',
                                'method' => 'POST'
                              ))}}
                          <div class="row">
                          <div class="col-md-8 col-md-offset-1">

                                   <div class="row">
                                  <div class="col-lg-5">
                                  <label>Tipe packaging</label>
                                  </div>
                                  <div class="col-lg-4">
                                    <select  class="form-control" name="packaging_type" style="width:200px;height:30px" >
                                      <option value="Kemasan pisah">Kemasan terpisah</option>
                                      <option value"Kemasan tidak pisah">Kemasan tidak terpisah</option>
                                    </select>
                                  </div>
                                  </div>
                                  <br>
                                  <div class="row">
                                  <div class="col-lg-5">
                                  <label>Nama kertas</label>
                                  </div>
                                  <div class="col-lg-4">
                                   <select  class="form-control" name="packaging_papertype_id" style="width:200px;height:30px" >
                                      <?php
$papers = DB::table('ref_papertype')
              ->where('papertype_type','=','packaging')
              ->get();
                                      ?>
                                      @foreach($papers as $paper)
                                      <option value="{{$paper->papertype_id}}">{{$paper->papertype_name}}</option>
                                      @endforeach
                                    </select>
                                  </div>
                                  </div>
                                  <br>
                                  <div class="row">
                                  <div class="col-lg-5">
                                  <label>Ukuran (dimensi) <font color="red"> *</font></label>
                                  </div>
                                  <div class="col-lg-7">
                                    <input type="text"  name="packaging_length" style="width:45px;height:30px" value="" /><strong> x </strong>
                                    <input type="text"  name="packaging_width" style="width:45px;height:30px" value="" /><strong> x </strong>
                                    <input type="text"  name="packaging_height" style="width:45px;height:30px" value="" /><strong> Cm </strong>
                                    <br><font color="red">Panjang x Lebar x Tinggi </font>
                                  </div>
                                  </div>
                                  <br>

                                  <div class="row">
                                  <div class="col-lg-5">
                                  <label>Harga <font color="red"> *</font></label>
                                  </div>
                                  <div class="col-lg-7">
                                    <input type="text"  class="form-control"  name="packaging_price" placeholder="Harga"style="width:200px;height:30px" value="" required /></input>
                                  </div>
                                  </div>
                                  <br>

                                    <div class="row">
                                    <div class="col-lg-5">
                                      <label>Qty </label>
                                    </div>
                                    <div class="col-lg-3">
                                     <input type="text"  class="form-control"  name="packaging_qty_price" placeholder="1000" style="width:90px;height:30px" value="" /></input>
                                    </div>
                                    <div class="col-lg-1">
                                     /
                                    </div>
                                    
                                    <div class="col-lg-3">
                                      <select  class="form-control"  name="packaging_qty_unit" style="width:80px;height:30px">
                                        <option value="Pcs">Pcs</option>
                                        <option value="Rim">Rim</option>
                                      </select>
                                    </div>
                                    </div>
                                    <br>
                                      <font color="red" class="text-left">* Data tidak boleh kosong</font>



                          </div>

                          </div>

                </div>


                    <div class="modal-footer">

                    <button type="submit" class="btn btn-sm btn-dark"><span class="fa fa-floppy-o"></span> Simpan</button>{{Form::close()}} <button class="btn btn-sm btn-dark" style="margin-right:5px" class="close" data-dismiss="modal"><span class="fa fa-times"></span> Batal</button></a>
                         
                    </div>
                  </div>
                </div>
              </div>

              @foreach($packagings as $packaging)
              <div class="modal fade" id="{{$packaging->packaging_id}}" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="false">
                <div class="modal-dialog modal-lg">
                  <div class="modal-content">
                    <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
 
                    <h4 align="center" class="modal-title"> <label style="margin-top:5px; margin-bottom:25px">Ubah data fitur tambahan </label></h4>
                    </div>
                    <div align="left">
                    <br>
                              {{Form::open(array(
                                    'url' => '/packaging/editpackaging/'.$packaging->packaging_id,
                                    'method' => 'POST'
                                  ))}}
                                <div class="row">
                                 <div class="col-md-8 col-md-offset-1">

                                   <div class="row">
                                  <div class="col-lg-5">
                                  <label>Tipe packaging</label>
                                  </div>
                                  <div class="col-lg-4">
                                    <select  class="form-control" name="packaging_type" style="width:200px;height:30px" >
                                       <?php
                                        $units = array('Kemasan terpisah' => 'Kemasan pisah','Kemasan tidak terpisah' => 'Kemasan tidak pisah');
                                        $qualityunit = $packaging->packaging_type;
                                        foreach($units as $key => $unit){
                                        if($unit == $qualityunit){
                                            echo '<option value="'.$unit.'" selected >'.$key.'</option>';
                                          }else{
                                            echo '<option value="'.$unit.'">'.$key.'</option>';
                                          }
                                        }
                                      ?>
                                    </select>
                                  </div>
                                  </div>
                                  <br>
                                  <div class="row">
                                  <div class="col-lg-5">
                                  <label>Nama kertas</label>
                                  </div>
                                  <div class="col-lg-4">
                                   <select  class="form-control" name="packaging_papertype_id" style="width:200px;height:30px" >
                                      @foreach($papers as $paper)
                                      <?php
                                      if($paper->papertype_id==$packaging->packaging_papertype_id){
                                      echo '<option value="'.$paper->papertype_id.'" selected>'.$paper->papertype_name.'</option>';
                                      }else{
                                      echo '<option value="'.$paper->papertype_id.'">'.$paper->papertype_name.'</option>';
                                      }
                                      ?>
                                      @endforeach
                                    </select>
                                  </div>
                                  </div>
                                  <br>
                                  <div class="row">
                                  <div class="col-lg-5">
                                  <label>Ukuran (dimensi) <font color="red"> *</font></label>
                                  </div>
                                  <div class="col-lg-7">
                                    <input type="text"  name="packaging_length" style="width:45px;height:30px" value="{{$packaging->packaging_length}}" /><strong> x </strong>
                                    <input type="text"  name="packaging_width" style="width:45px;height:30px" value="{{$packaging->packaging_width}}" /><strong> x </strong>
                                    <input type="text"  name="packaging_height" style="width:45px;height:30px" value="{{$packaging->packaging_height}}" /><strong> Cm </strong>
                                    <br><font color="red">Panjang x Lebar x Tinggi </font>
                                  </div>
                                  </div>
                                  <br>

                                  <div class="row">
                                  <div class="col-lg-5">
                                  <label>Harga <font color="red"> *</font></label>
                                  </div>
                                  <div class="col-lg-7">
                                    <input type="text"  class="form-control"  name="packaging_price" placeholder="Harga"style="width:200px;height:30px" value="{{$packaging->packaging_price}}" required /></input>
                                  </div>
                                  </div>
                                  <br>

                                    <div class="row">
                                    <div class="col-lg-5">
                                      <label>Qty </label>
                                    </div>
                                    <div class="col-lg-3">
                                     <input type="text"  class="form-control"  name="packaging_qty_price" placeholder="1000" style="width:90px;height:30px" value="{{$packaging->packaging_qty_price}}" /></input>
                                    </div>
                                    <div class="col-lg-1">
                                     /
                                    </div>
                                    
                                    <div class="col-lg-3">
                                      <select  class="form-control"  name="packaging_qty_unit" style="width:80px;height:30px">
                                        <?php
                                        $units = array('Pcs','Rim');
                                        $qualityunit = $packaging->packaging_qty_unit;
                                        foreach($units as $key => $unit){
                                        if($unit == $qualityunit){
                                            echo '<option value="'.$unit.'" selected >'.$unit.'</option>';
                                          }else{
                                            echo '<option value="'.$unit.'">'.$unit.'</option>';
                                          }
                                        }
                                      ?>
                                      </select>
                                    </div>
                                    </div>
                                    <br>
                                      <font color="red" class="text-left">* Data tidak boleh kosong</font>



                          </div>

                          </div>  
                    
                    </div>
                    <div class="modal-footer">

                    <button type="submit" class="btn btn-sm btn-dark"><span class="fa fa-floppy-o"></span> Simpan</button>{{Form::close()}} <button class="btn btn-sm btn-dark" style="margin-right:5px" class="close" data-dismiss="modal"><span class="fa fa-times"></span> Batal</button></a>
                         
                    </div>
                  </div>
                </div>
              </div>
              @endforeach

</div>
@stop
@stop